import Cookies from 'js-cookie'

const TokenKey = 'shangrui'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setStorage(key, value) {
  window.localStorage.setItem(
    TokenKey + '-' + key,
    typeof value === 'object' ? JSON.stringify(value) : value
  )
}
export function getStorage(key) {
  return window.localStorage.getItem(TokenKey + '-' + key)
}
export function rmStorage(key) {
  window.localStorage.removeItem(TokenKey + '-' + key)
}
